package com.tesserate.timecontrol.clock;

public class Clock {
    public static final int READY = 0;
    public static final int STARTED = 1;
    public static final int PAUSED = 2;
    public static final int STOPED = 10;
    
    private int state = READY;
    private long time = 0;
    
    public boolean isReady() { return state == READY; }; 
    public boolean isStarted() { return state == STARTED; }; 
    public boolean isPaused() { return state == PAUSED; }; 
    public boolean isStoped() { return state == STOPED; }; 
    
	public void start(){
		if(isReady() || isPaused()){
			this.state = STARTED;
		}
	}
	
	public void stop(){
		this.state = STOPED;
	}
	
	public void pause(){
		if(isStarted())
			this.state = PAUSED;
	}
	
	public void reset(){
		this.time = 0;
		this.state = READY;
	}
	
	public void update(long elapsedTime){
		if(isStarted())
			this.time += elapsedTime;
	}
	public long getTime() {
		return time;
	}
}
